    <?php $this->load->view('user/user_head');?>
    <script src="<?php echo base_url()?>/js/page/jquery.pagination.js" type="text/javascript"></script>
    <script type="text/javascript" src="<?php echo base_url();?>js/common.js"></script>
    <link href="<?php echo base_url();?>js/page/pagination.css" rel="stylesheet" type="text/css"/>
    <link href="<?php echo base_url();?>js/thickbox/thickbox.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="<?php echo base_url();?>js/thickbox/thickbox.js"></script>

    <script language="javascript">
    $(function(){
    	var i_flag = $.trim($('#i_flag').val());
		if(i_flag != "") {
			$('.a_radio').each(function() {
				$(this).attr('checked', '');
				if ($(this).val() == i_flag) {
					$(this).attr('checked', 'checked');
				}
			});
		}
		
		var b_i_category = $.trim($('#b_i_category').val());
		if (b_i_category == "") {
			$('#i_category_span').text("请选择");
		} else {
			$('#i_category_span').text(get_guest_b_category_by_id(i_category));
		}


		
		var i_category = $.trim($('#i_category').val());
		if (i_category == "" && b_i_category == "") {
			$('#i_category_span').text("请选择");
		} else {
			$('#i_category_span').text(get_guest_category_by_id(i_category));
		}
		
		//表格交替变色
		$("table.datalist tr:nth-child(odd)").addClass("altrow");
		//大分类选择
		$(".big_category").click(function() {
			$('#b_i_category').val(this.title);
			$('#i_category').val('');
			$('#i_category_span').text($(this).text());
			tb_remove();
		});
		//小分类选择
		$(".s_category").click(function() {
			$('#b_i_category').val('');
			$('#i_category').val(this.title);
			$('#i_category_span').text($(this).text());
			tb_remove();
		});
		//按钮事件处理
		$('#search_button').click(function() {
			ajax_search();
		});
		//重置查询事件处理
		$('#reset_button').click(function() {
			$('#b_i_category').val('');
			$('#i_category').val('');
			$('#i_flag').val('');
			$('#i_category_span').text('请选择');
			$('.a_radio').attr('checked', '');	
			$('#guest_list').html('');
			$("#Pagination").html('');			
		});
	    <?php if(isset($condition)):?>
			ajax_search();
    	<?php endif;?>
		
	});
	
	function ajax_search() {
		var url =  "<?php echo base_url();?>/index.php/user/guestAction/ajax_count";
		$.post(url, get_form_data(), function(data) {
			$('#total_count').val(data);
			if ($('#total_count').val() == "0") {
				$("#Pagination").html("");
				 $("#guest_list").html("没有查找到数据！");
			}  else {
				var opt = {callback:pageselectCallback, items_per_page:10, num_display_entries:3, num_edge_entries:2, next_text:'下一页', prev_text:'上一页'};
			    $("#Pagination").pagination($('#total_count').val(), opt);
			}
		});
	}
		
	function get_form_data() {
		$('.a_radio').each(function() {
			
			if ($(this).attr('checked')) {
				$('#i_flag').val($(this).val());
			}
		});

	
		var data = {i_name:$('#i_name').val(),
				 i_flag:$('#i_flag').val(), 
				 b_i_category:$('#b_i_category').val(), 
				 i_category:$('#i_category').val()
				 };
		 return data;
	}

	function pageselectCallback(page_index, jq){
		var offset = page_index * 10;
 	   	var f_data = get_form_data();
 	   	f_data['offset'] = offset;
  	    var url =  "<?php echo base_url();?>/index.php/user/guestAction/ajax_search";
	    $.ajax({
	  	      type: "POST",
	  		  url: url,
	  		  cache: false,
	  		  data: f_data,
	  		  dataType : "html",
	  		  success: function(html) {
	  		  	
	  		    $("#guest_list").html(html);
	  		  }
	  		}); 
	    return false;
	}
    </script>
    
    <input type="hidden" id="page_code" value="5"/>
    <input type="hidden" id="total_count" value=""/>
    <!-- begin: main content area #main -->
     <div id="main">
      <!-- begin: #col1 - first float column -->
      <div id="col1" role="complementary">
         <?php $this->load->view('user/guest_left_nav.php')?>
      </div>
      <!-- end: #col1 -->
      <!-- begin: #col3 static column -->
      <div id="col3" role="main">
        <div id="col3_content" class="clearfix">
            <div class="sys_help_msg_box" style="height:100px;margin-bottom:10px;">
	        	<p style="margin:20px 10px 0 20px;"><strong style="color:#d02200">温馨提示:</strong>
	        	邀请来宾管理、可以提醒您及时联系各位来宾、确保亲朋好友参加您的婚宴！
				还可以通过此项功能、预测礼金哦、预算一下大家能够给你随多少银两；等婚礼结束后与礼金管理配合使用看看哪位仁兄尚未到场！此项功能
				还可以与婚礼预算配合使用，用于预算婚礼的收支平衡!
	        	</p>
            </div>
            
            <div id="search_guest" class="search_div">
            	<p style="margin:20px 10px 10px 20px;">
            		<strong style="color:#d02200">婚礼邀请来宾查询</strong><br /><br />
            		<strong style="color:#d02200">姓名：</strong><input type="text" id="i_name"/>
            		<strong style="color:#d02200">邀请状态：</strong><input class="a_radio" value="0" type="radio" name="i_flag_radio"/>已邀请 <input class="a_radio" value="1" type="radio" name="i_flag_radio"/>未邀请
            	</p>
            	<p style="margin:0 10px 30px 20px;">
            	    <input id="b_i_category" type="hidden" value="<?php echo isset($condition) ? $condition['b_i_category'] : '';?>"/>
            	    <input id="i_category" type="hidden" value="<?php echo isset($condition) ? $condition['i_category'] : '';?>"/>
            	    <input id="i_flag" type="hidden" value="<?php echo isset($condition) ? $condition['i_flag'] : '';?>"/>
	            	<strong style="color:#d02200">邀请人类型：</strong><span id="i_category_span">未选择</span>
			        <a href="#TB_inline?height=300&width=450&inlineId=i_category_div" class="thickbox">【选择来宾类型】</a><br /><br />
            		<button id="search_button" style="padding:1px 4px;">搜索</button>
            		<button id="reset_button" style="padding:1px 4px;">重置查询</button>
            	</p>
            </div>
            
            <div id="guest_list" style="margin-top:10px;"></div>
            <div id="Pagination" class="pagination"></div>	

        </div>
        <div id="ie_clearing">&nbsp;</div>
        <!-- End: IE Column Clearing -->
      </div>
      <!-- end: #col3 -->
    </div>
    <!-- end: #main -->
	<div id="i_category_div" style="display:none">
    	<div id="i_category_div_info">
    	
    	    <span class="big_category" title="1">新郎邀请来宾</span>
    	    <span class="big_category" title="2">新娘邀请来宾</span>
    	    <span class="big_category" title="3">娘家邀请来宾</span>
    	    <span class="big_category" title="4">婆家邀请来宾</span>
    	
    	    <hr />
    	    <p style="margin-left:15px;">
	    	新郎邀请来宾：<span class="s_category" title="1">新郎同学</span>
			<span class="s_category" title="2">新郎朋友</span>
			<span class="s_category" title="3">新郎同事</span>
			<br /><br />
	    	新娘邀请来宾：<span class="s_category" title="4">新娘同学</span>
			<span class="s_category" title="5">新娘朋友</span>
			<span class="s_category" title="6">新娘同事</span>
			<br /><br />
			娘家邀请来宾：<span class="s_category" title="7">娘家亲属</span>
		  	<span class="s_category" title="8">娘家朋友</span>
		  	<span class="s_category" title="9">娘家同事</span>
		  	<br /><br />
		  	婆家邀请来宾：<span class="s_category" title="10">婆家亲属</span>
		  	<span class="s_category" title="11">婆家朋友</span>
		  	<span class="s_category" title="12">婆家同事</span>
		  	</p>
	  	</div>
    </div>
<?php $this->load->view('user/footer');?>